<template>

</template>

<script>
import { useGlobalStore } from "@/stores/globalStore";
export default {
  name: "Role",
  data() {
    let validateRoleName = (rule, value, callback) => {
      if (!value) {
        callback(new Error("角色名不能为空"))
      } else {
        if (value !== "") {
          let item = this.tableData.filter(it=> it.name === value)
          if(item.length >0) callback(new Error('角色名与已有角色名重复!'));
        }        
        callback();
      }
    };
    let validateFlagName = (rule, value, callback) => {
      if (!value) {
        callback(new Error("标识不能为空"))
      } else {
        if (value !== "") {
          let item = this.tableData.filter(it=> it.flag === value)
          if(item.length >0) callback(new Error('标识名与已有标识名重复!'));
        }        
        callback();
      }
    };
    return {
      tableData: [],
      total: 0,
      pageNum: 1,
      pageSize: 10,
      name: '',
      description: '',
      form: {},
      formRlues: {
        name: [
          { required: true, validator: validateRoleName, trigger: 'blur' }
        ],
        description: [
          { required: true, message: '请输入描述', trigger: 'blur' }
        ],
        flag: [
          { required: true, validator: validateFlagName, trigger: 'blur' }
        ]
      },
      multipleSelection: [],
      headerBg: 'headerBg',
      dialogFormVisible: false,
      menuDialogVisible: false,
      menuData: [],
      props: {
        label: 'name',
      },
      expends: [],
      checks: [],
      roleId: 0,
      roleFlag: '',
      delBtlStatus: true,
      loading: false
    }
  },
}
</script>
